import { Controller, Get, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';
import { JwtAuthGuard } from './auth/guards/jwt-auth.guard';
import { CurrentUser } from './auth/decorators/current-user.decorator';
import { User } from './types/user.interface';

/**
 * 应用程序根控制器
 * 处理HTTP请求并返回响应
 */
@Controller()
export class AppController {
  /**
   * 构造函数注入AppService
   * @param appService - 应用服务实例，用于处理业务逻辑
   */
  constructor(private readonly appService: AppService) {}

  /**
   * 获取欢迎消息
   * @returns 欢迎字符串
   * @example GET / → "Hello World!"
   */
  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  /**
   * 获取当前登录用户信息
   * @returns 当前登录用户信息
   */
  @Get('profile')
  @UseGuards(JwtAuthGuard)
  getProfile(@CurrentUser() user: User) {
    return user;
  }
}
